<?php
session_start();
// Error Reporting
error_reporting(E_ALL ^ E_NOTICE);

// RegEx
define('EMAIL_PATTERN', '/^[^\@]+@.*\.[a-z]{2,6}$/i');

// Check Version
if (version_compare(phpversion(), '5.1.0', '<') == TRUE) {
	exit('PHP5.1+ Required');
}

// Register Globals
if (ini_get('register_globals')) {
	ini_set('session.use_cookies', 'On');
	ini_set('session.use_trans_sid', 'Off');
		
	session_set_cookie_params(0, '/');
	session_start();
	
	$globals = array($_REQUEST, $_SESSION, $_SERVER, $_FILES);

	foreach ($globals as $global) {
		foreach(array_keys($global) as $key) {
			unset($$key);
		}
	}
}

// Magic Quotes Fix
if (ini_get('magic_quotes_gpc')) {
	function clean($data) {
   		if (is_array($data)) {
  			foreach ($data as $key => $value) {
    			$data[clean($key)] = clean($value);
  			}
		} else {
  			$data = stripslashes($data);
		}
	
		return $data;
	}			
	
	$_GET = clean($_GET);
	$_POST = clean($_POST);
	$_COOKIE = clean($_COOKIE);
}

if (!ini_get('date.timezone')) {
	date_default_timezone_set('UTC');
}

define('BASE_PATH',dirname(dirname(__FILE__)));
define('CONFIG_PATH',BASE_PATH.DS."config");
define('MODULE_PATH',BASE_PATH.DS."module");
define('LIB_PATH',BASE_PATH.DS ."library");
define('TEMPLATE_PATH',LIB_PATH.DS.'smarty');
define('INCLUDE_PATH',BASE_PATH.DS ."include");
define('MODEL_PATH',BASE_PATH.DS ."model");
define("SESSION_ID", "cd_shop");

//数据库配置
require_once CONFIG_PATH.DS.'db.conf.php';
//公共函数
require_once INCLUDE_PATH.DS.'common.func.php';
//数据库类
//include_once LIB_PATH.DS.'mysql.class.php';
require_once LIB_PATH.DS.'registry.class.php';
require_once LIB_PATH.DS.'db.class.php';
require_once LIB_PATH.DS.'mysql.php';
require_once LIB_PATH.DS.'model.class.php';
require_once LIB_PATH.DS.'tree.class.php';
?>